/**
* 左边菜单
*/
<template>
	<el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path"
		unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff"
		active-text-color="#ffd04b">
		<div class="logobox">
			<span>后台系统</span>
		</div>

		<el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
			<template slot="title">
				<i :class="menu.icon"></i>
				<span>{{menu.menuname}}</span>
			</template>
			<el-menu-item-group>
				<el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
					<!--  <i class="iconfont" :class="chmenu.icon"></i> -->
					<i :class="chmenu.icon"></i>
					<span>{{chmenu.menuname}}</span>
				</el-menu-item>
			</el-menu-item-group>
		</el-submenu>
	</el-menu>
</template>
<script>
	export default {
		name: 'leftnav',
		data() {
			return {
				collapsed: false,
				allmenu: []
			}
		},
		// 创建完毕状态(里面是操作)
		created() {
			// 获取图形验证码
			let res = {
				success: true,
				data: [{
						menuid: 1,
						icon: 'el-icon-s-home',
						menuname: '首页',
						hasThird: null,
						url: null,
						menus: [{
							menuid: 2,
							icon: 'el-icon-s-data',
							menuname: '各类数据统计',
							hasThird: 'N',
							url: 'home/index',
							menus: null
						}]
					},
					{
						menuid: 10,
						icon: 'el-icon-s-home',
						menuname: '项目管理',
						hasThird: null,
						url: null,
						menus: [{
								menuid: 13,
								icon: 'el-icon-s-order',
								menuname: '楼盘管理',
								hasThird: 'N',
								url: 'project/property',
								menus: null
							}, {
								menuid: 14,
								icon: 'el-icon-s-order',
								menuname: '楼层管理',
								hasThird: 'N',
								url: 'project/floors',
								menus: null
							}, {
								menuid: 15,
								icon: 'el-icon-s-order',
								menuname: '房屋信息管理',
								hasThird: 'N',
								url: 'project/house',
								menus: null
							}, {
								menuid: 16,
								icon: 'el-icon-s-order',
								menuname: '周边环境',
								hasThird: 'N',
								url: 'project/around_environment',
								menus: null
							}, {
								menuid: 17,
								icon: 'el-icon-s-order',
								menuname: '预约看房',
								hasThird: 'N',
								url: 'project/appointments',
								menus: null
							},
							{
								menuid: 18,
								icon: 'el-icon-s-order',
								menuname: '房屋类型',
								hasThird: 'N',
								url: 'project/type',
								menus: null
							},
						]
					},
					{
						menuid: 2,
						icon: 'el-icon-user-solid',
						menuname: '用户',
						hasThird: null,
						url: null,
						menus: [{
							menuid: 21,
							icon: 'el-icon-user',
							menuname: '用户',
							hasThird: 'N',
							url: 'user/user',
							menus: null
						}, {
							menuid: 22,
							icon: 'el-icon-user',
							menuname: '顾问',
							hasThird: 'N',
							url: 'user/adviser',
							menus: null
						}]
					},
					{
						menuid: 3,
						icon: 'el-icon-s-shop',
						menuname: '活动',
						hasThird: null,
						url: null,
						menus: [{
								menuid: 31,
								icon: 'el-icon-s-open',
								menuname: '大转盘',
								hasThird: 'N',
								url: 'active/turntable_actives',
								menus: null
							},
							{
								menuid: 32,
								icon: 'el-icon-s-open',
								menuname: '最新咨询',
								hasThird: 'N',
								url: 'active/article',
								menus: null
							},
              {
              		menuid: 32,
              		icon: 'el-icon-present',
              		menuname: '盲盒奖品',
              		hasThird: 'N',
              		url: 'active/blind_box',
              		menus: null
              	}
						]
					},
					{
						menuid: 5,
						icon: 'el-icon-setting',
						menuname: '系统',
						hasThird: null,
						url: null,
						menus: [{
								menuid: 51,
								icon: 'el-icon-s-tools',
								menuname: '系统配置',
								hasThird: 'N',
								url: 'sys/sys',
								menus: null
							},
							{
								menuid: 52,
								icon: 'el-icon-s-tools',
								menuname: '首页设置',
								hasThird: 'N',
								url: 'sys/home_sets',
								menus: null
							},
							{
								menuid: 53,
								icon: 'el-icon-s-tools',
								menuname: '广告管理',
								hasThird: 'N',
								url: 'sys/banner',
								menus: null
							},
							{
								menuid: 54,
								icon: 'el-icon-s-tools',
								menuname: '导航管理',
								hasThird: 'N',
								url: 'sys/nav',
								menus: null
							},
							{
								menuid: 55,
								icon: 'el-icon-s-tools',
								menuname: '消息管理',
								hasThird: 'N',
								url: 'sys/notice',
								menus: null
							},
							{
								menuid: 56,
								icon: 'el-icon-s-tools',
								menuname: '直播间广告图',
								hasThird: 'N',
								url: 'sys/play_banners',
								menus: null
							},
							{
								menuid: 57,
								icon: 'el-icon-s-tools',
								menuname: '资讯分类',
								hasThird: 'N',
								url: 'sys/article_cate',
								menus: null
							},
							{
								menuid: 58,
								icon: 'el-icon-s-tools',
								menuname: '图片广告',
								hasThird: 'N',
								url: 'sys/image_banners',
								menus: null
							},
							{
								menuid: 59,
								icon: 'el-icon-s-tools',
								menuname: '全面营销表单',
								hasThird: 'N',
								url: 'sys/marketing_form',
								menus: null
							},

						]
					},
					{
						menuid: 6,
						icon: 'el-icon-aim',
						menuname: '日志',
						hasThird: null,
						url: null,
						menus: [{
								menuid: 61,
								icon: 'el-icon-message',
								menuname: '养鸡日志',
								hasThird: 'N',
								url: 'logs/egg_logs',
								menus: null
							},
							{
								menuid: 62,
								icon: 'el-icon-message',
								menuname: '抽奖日志',
								hasThird: 'N',
								url: 'logs/turntable_logs',
								menus: null
							},
              {
              	menuid: 63,
              	icon: 'el-icon-message',
              	menuname: '种树日志',
              	hasThird: 'N',
              	url: 'logs/tree_logs',
              	menus: null
              }

						]
					},
          {
          	menuid: 7,
          	icon: 'el-icon-s-grid',
          	menuname: '核销记录',
          	hasThird: null,
          	url: null,
          	menus: [{
          			menuid: 71,
          			icon: 'el-icon-menu',
          			menuname: '红包核销记录',
          			hasThird: 'N',
          			url: 'writeoff/red_writeoffd',
          			menus: null
          		}

          	]
          },
          {
          	menuid: 8,
          	icon: 'el-icon-notebook-1',
          	menuname: '套餐',
          	hasThird: null,
          	url: null,
          	menus: [{
          			menuid: 81,
          			icon: 'el-icon-notebook-2',
          			menuname: '套餐',
          			hasThird: 'N',
          			url: 'package/package',
          			menus: null
          		},
              {
              		menuid: 82,
              		icon: 'el-icon-notebook-2',
              		menuname: '订单',
              		hasThird: 'N',
              		url: 'package/order',
              		menus: null
              	}

          	]
          }
				],
				msg: 'success'
			}
			this.allmenu = res.data

			// 监听
			this.$root.Bus.$on('toggle', value => {
				this.collapsed = !value
			})
		}
	}
</script>
<style>
	.el-menu-vertical-demo:not(.el-menu--collapse) {
		width: 240px;
		min-height: 400px;
	}

	.el-menu-vertical-demo:not(.el-menu--collapse) {
		border: none;
		text-align: left;
	}

	.el-menu-item-group__title {
		padding: 0px;
	}

	.el-menu-bg {
		background-color: #1f2d3d !important;
	}

	.el-menu {
		border: none;
	}

	.logobox {
		height: 40px;
		line-height: 40px;
		color: #9d9d9d;
		font-size: 20px;
		text-align: center;
		padding: 20px 0px;
	}

	.logoimg {
		height: 40px;
	}
</style>
